<template>
  <div>
    <button @click="fn">去主页</button>
    <button @click="fn2">去登陆页</button>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  methods: {
    fn() {
      this.$router.push("/home");
    },
    fn2() {
      // this.$router.push("/login");
      // this.$router.push({
      //   path: "/login",
      //   query: {
      //     id: 1,
      //     name: "参数值2",
      //   },
      // });

      //要用name
      //query也可以使用name
      this.$router.push({
        name: "login",
        params: {
          id: 100,
          name: "3122",
        },
      });
    },
  },
};
</script>

<style>
</style>